home *** CD-ROM | disk | FTP | other *** search
- Path: news.bbn.com!cbarber
- From: cbarber@bbn.com (Christopher Barber)
- Newsgroups: comp.lang.c++
- Subject: Re: Coding Standards
- Date: 18 Mar 1996 15:46:44 GMT
- Organization: BBN
- Message-ID: <CBARBER.96Mar18104644@figaro.bbn.com>
- References: <4hj8ek$elu@sam.inforamp.net> <4hktar$5o2@galaxy.ucr.edu>
- <4hmqol$97j@abacus.abasoft.co.uk> <4hsg8r$pmm@sam.inforamp.net>
- <4i9o6j$p4l@daisy.pgh.wec.com> <4idskb$pc1@sam.inforamp.net>
- NNTP-Posting-Host: figaro.bbn.com
- In-reply-to: rmorin@inforamp.net's message of Sat, 16 Mar 96 08:03:03 GMT
-
-
- >>>>> "Randy" == Randy Charles Morin <rmorin@inforamp.net> writes:
-
- Randy> You see, I've worked on dozens of projects and most of them had
- Randy> coding standards. And most of those coding standards were
- Randy> reasonable. This coding standard was a joke. You see, the
- Randy> company even agreed that our group would not have to follow the
- Randy> guidelines, because they were devised by an inexperienced group
- Randy> that were not aware of the world outside of character based
- Randy> Unix. But, a couple of you inexperienced programmers have to
- Randy> pull a hollier than thou routine.
- ^^^^^^^
-
- Maybe becase we are all *ivy* leaguers? ;`)
-
- Randy> I received many responses
- Randy> from users who agreed that the standards were a joke. Some of
- Randy> these were even posted publicly.
-
- Some of those were sarcastic!
-
- Randy> ------- -source files should have the extension .cc (not .cpp or
- Randy> .c). I don't think I have to say anything here.
-
- Randy> -header files should have the extension .hh (not .hpp or
- Randy> .h). I don't think I have to say anything here.
-
- Sure you do. Do you really consider this an argument?
-
- I think that it is perfectly reasonable to specify standard suffixes for
- source files and the ones chosen are not unreasonable. Why confuse poor
- entry level programmers with multiple suffixes for C++ code?
-
- Clearly .c would be a really stupid choice for C++ code because there would
- be no way for a makefile to know when to use the C compiler and when to use
- C++. For you to even suggest it as an option, indicates to me that your
- judgement is impaired.
-
- I think it is ok to use .h as an extension, but only if it can be used
- with C code.
-
- Randy> -inline C++ functions should be in a file with the
- Randy> extension .icc (not in the primary header). I don't think I
- Randy> have to say anything here either. But, I will. Although I've
- Randy> seen many people do this, it is contrary to normal industry
- Randy> practices. By using non-standard practices you increase the
- Randy> learning necessary for new employees. Bad.
-
- There is no such thing as "normal industry practices". Although a bit
- extreme, this convention does have some advantages:
-
- - it keeps code out of the header in the spirit of seperating
- interface and implementation
- - it makes it relatively easy to switch between inlined and
- non-inlined code.
-
- Randy> -do not use the /* */ comment, except when commenting out
- Randy> entire sections of code. /* */ are the ANSI standard comment.
- Randy> // are not. When you have a parameter not used warning, you
- Randy> should eliminate it using. void f(int /* idControl */); You
- Randy> can't do this with //. You could also delete the identifier,
- Randy> but then you would lose context.
-
- Very true. This is a place where the /* */ comments would be useful.
- But generally, it is easier to do special comment processing in smart
- editors if you use the // style comments, so I think that the rule is
- ok as long as you recognize that there are some places where the old
- style comments will make more sense.
-
- Randy> -a class which can be instantiated with a "new" must have a
- Randy> copy constructor, a destructor and an assignment operator
- Randy> definition. Most compilers (if not all) supply default copy
- Randy> construtors. Unless you think your class may have copy behavior
- Randy> problems, then writing copy constructors is redundant. When you
- Randy> have 100+ classes to write and where the average copy
- Randy> constructor has 50 lines, you would need 100 hours to write the
- Randy> additional robustness (or cumbersomeness).
-
- Aren't you getting a bit extreme here? I have written hundreds of
- copy constructors and only a handful came even close to 50 lines long.
- Yes, the compiler will generate a copy constructor for you, but it
- has the wrong behavior in many cases.
-
- Randy> -never use #define instead or const. This is a good
- Randy> debate, but I still maintain that if your memory model and
- Randy> compiler make #define data text and const code text, then you
- Randy> cannot consider this a straight forward trade-off.
-
- Didn't you say this was a Unix project? There is no such thing
- as a "memory model" in Unix.
-
- Anyway, enough of this. Some of the rules are a bit extreme or silly.
- But many are quite reasonable and you don't seem to be able to distinguish
- between the two.
-
- cheers,
-
- - Chris
- --
- Christopher Barber ----- Software Engineer ---- BBN Systems and Technologies
-